如何使 <select> 不可选

来源:百度知道 编辑:UC知道 时间:2024/06/19 13:25:56
比如有一个
<select>
<option>大</option>
<option>中</option>
<option>小</option>
</select>

如何使用 js 使其固定在某个选项上不能改变

<select onchange="reset(this)" value="zhong">
<option value="da">大</option>
<option value="zhong" selected>中</option>
<option value="xiao">小</option>
</select>
<script>
function reset(ele){
var oChildren = ele.childNodes;
var value = ele.getAttribute('value');
for(var i=0;i<oChildren.length;i++){
if(oChildren[i].tagName=='OPTION'){
if(oChildren[i].value==value){
oChildren[i].selected = true;
}
}
}
}
</script>
不明白Hi我